﻿///<reference path="../typings/jquery/jquery.d.ts"/>
///<reference path="../typings/linq/linq.3.0.3-Beta4.d.ts"/>
///<reference path="../typings/knockout/knockout.d.ts"/>

module Enferno.Public.Shopping {

    export class Promotion {

        public id: number;
        public header: string;
        public shortDescription: string;
        public description1: string;
        public description2: string;
        public discountCode: string;
        public name: string;
        public startDate: Date;
        public endDate: Date;
        public imageUrl: string;
        public requirementSeed: string;

        constructor(serverObject?: any) {
            if (serverObject != null) {
                this.id = serverObject.id;
                this.header = serverObject.header;
                this.shortDescription = serverObject.shortDescription;
                this.description1 = serverObject.description1;
                this.description2 = serverObject.description2;
                this.discountCode = serverObject.discountCode;
                this.name = serverObject.name;
                if (serverObject.startDate != null)
                    this.startDate = new Date(serverObject.startDate);
                if (serverObject.endDate != null)
                    this.endDate = new Date(serverObject.endDate);

                this.imageUrl = serverObject.imageUrl;
                this.requirementSeed = serverObject.requirementSeed;
            }
        }
    }

    export class PromotionApplicationResult {
        public appliedPromotion: Promotion;
        public basket: Basket;

        constructor(serverData?: any) {
            if (serverData != null) {

                if (serverData.appliedPromotion != null) {
                    this.appliedPromotion = new Promotion(serverData.appliedPromotion);
                }

                if (serverData.basket != null) {
                    this.basket = new Basket(serverData.basket);
                }
            }
        }
    }

} 